package src;

import pjwstk.jps.datastore.*;
import pjwstk.jps.interpreter.envs.*;
import pjwstk.jps.interpreter.qres.QResStack;
import pjwstk.jps.ast.*;
import pjwstk.jps.ast.auxname.AsExpression;
import pjwstk.jps.ast.auxname.GroupAsExpression;
import pjwstk.jps.ast.binary.*;
import pjwstk.jps.ast.terminal.*;
import pjwstk.jps.ast.unary.*;
import pjwstk.jps.result.*;

/**
 * @author s9111_s10304
 *
 */
public class Main5
{
    @SuppressWarnings("unused")
    public static void main(String[] args) {
        // pr5 - Operatory I
        System.out.println("pr5 - Operatory I");
        
        ENVS envs1 = new ENVS();           // envs1||
        QResStack qres1 = new QResStack(); // qres1||
        SBAStore store1 = new SBAStore();  // store1||
        
        store1.loadXML(".\\s9111_s10304_pr5\\res\\data.xml");
        envs1.init(store1.getEntryOID(), store1); // envs1|| integerNumber(1), emp(2), emp(15), realNumber(25)
        store1.PrintObjects(store1.retrieve(store1.getEntryOID()));
        System.out.println(store1.getString());
        
        Interpreter interpreter = new Interpreter(store1);
        
        
        IExpression someExpression = 
        		new EqualsExpression(
        				new NameTerminal("integerNumber"),
        				new IntegerTerminal(10)
        		);
        
        IAbstractQueryResult someRes = interpreter.eval(someExpression);
        System.out.println(someRes.toString());
        
        // plus
        IExpression expression1 = 
                new PlusExpression(
                        new IntegerTerminal(2),
                        new NameTerminal("integerNumber")
                );
        
        IAbstractQueryResult queryResult1 = interpreter.eval(expression1);
        System.out.println("2 + 10 = "+queryResult1.toString());
        
        // minus
        IExpression expression2 = 
                new MinusExpression(
                        new NameTerminal("integerNumber"),
                        new NameTerminal("realNumber")
                );
        
        IAbstractQueryResult queryResult2 = interpreter.eval(expression2);
        System.out.println("10 - 234.35 = "+queryResult2.toString());
        
        // mult
        IExpression expression3 = 
                new MultiplyExpression(
                        new NameTerminal("integerNumber"),
                        new IntegerTerminal(3)
                );
        
        IAbstractQueryResult queryResult3 = interpreter.eval(expression3);
        System.out.println("10 * 3 = "+queryResult3.toString());
        
        // div
        IExpression expression4 = 
                new DivideExpression(
                        new NameTerminal("integerNumber"),
                        new NameTerminal("integerNumber")
                );
        
        IAbstractQueryResult queryResult4 = interpreter.eval(expression4);
        System.out.println("10 div 10 = "+queryResult4.toString());
        
        // mod
        IExpression expression5 = 
                new ModuloExpression(
                        new NameTerminal("integerNumber"),
                        new NameTerminal("integerNumber")
                );
        
        IAbstractQueryResult queryResult5 = interpreter.eval(expression5);
        System.out.println("10 mod 10 = "+queryResult5.toString());
        
        // or
        IExpression expression6 = 
                new OrExpression(
                        new GreaterThanExpression(
                                new NameTerminal("integerNumber"),
                                new NameTerminal("integerNumber")
                        ),
                        new GreaterThanExpression(
                                new NameTerminal("integerNumber"),
                                new IntegerTerminal(3)
                        )
                );
        
        IAbstractQueryResult queryResult6 = interpreter.eval(expression6);
        System.out.println("(10 > 10) or (10 > 3) = "+queryResult6.toString());

        // and
        IExpression expression7 = 
                new AndExpression(
                        new GreaterThanExpression(
                                new NameTerminal("integerNumber"),
                                new IntegerTerminal(4)
                        ),
                        new GreaterThanExpression(
                                new NameTerminal("integerNumber"),
                                new NameTerminal("integerNumber")
                        )
                );
        
        IAbstractQueryResult queryResult7 = interpreter.eval(expression7);
        System.out.println("(10 > 4) and (10 > 10) = "+queryResult7.toString());

        // xor
        IExpression expression8 = 
                new XORExpression(
                        new GreaterThanExpression(
                                new NameTerminal("integerNumber"),
                                new IntegerTerminal(2)
                        ),
                        new GreaterThanExpression(
                                new NameTerminal("integerNumber"),
                                new IntegerTerminal(3)
                        )
                );
        
        IAbstractQueryResult queryResult8 = interpreter.eval(expression8);
        System.out.println("(10 > 2) xor (10 > 3) = "+queryResult8.toString());

        // xor
        IExpression expression9 = 
                new XORExpression(
                        new GreaterThanExpression(
                                new NameTerminal("integerNumber"),
                                new NameTerminal("realNumber")
                        ),
                        new GreaterThanExpression(
                                new NameTerminal("realNumber"),
                                new NameTerminal("integerNumber")
                        )
                );
        
        IAbstractQueryResult queryResult9 = interpreter.eval(expression9);
        System.out.println("(10 > 234.35) xor (234.35 > 10) = "+queryResult9.toString());
        
        // >=
        IExpression expression10 = 
                 new GreaterOrEqualThanExpression(
                         new NameTerminal("realNumber"),
                         new NameTerminal("integerNumber")
                 );
        
        IAbstractQueryResult queryResult10 = interpreter.eval(expression10);
        System.out.println("(234.35 >= 10) = "+queryResult10.toString());

        // <=
        IExpression expression11 = 
                 new LessOrEqualThanExpression(
                         new NameTerminal("realNumber"),
                         new NameTerminal("realNumber")
                 );
        
        IAbstractQueryResult queryResult11 = interpreter.eval(expression11);
        System.out.println("(234.35 <= 234.35) = "+queryResult11.toString());

        // <
        IExpression expression12 = 
                 new LessThanExpression(
                         new NameTerminal("realNumber"),
                         new NameTerminal("integerNumber")
                 );
        
        IAbstractQueryResult queryResult12 = interpreter.eval(expression12);
        System.out.println("(234.35 < 10) = "+queryResult12.toString());
/*
        // or
        IExpression expression13 = 
                new OrExpression(
                        new DotExpression(
                                new NameTerminal("emp"),
                                new NameTerminal("married")
                        ),
                        new DotExpression(
                                new NameTerminal("emp"),
                                new NameTerminal("married")
                        )
                );
        
        IAbstractQueryResult queryResult13 = interpreter.eval(expression13);
        System.out.println("emp.married or emp.married = "+queryResult13.toString());
*/      
        // -
        IExpression expression14 =
             new MinusExpression(
                new BagExpression(new NameTerminal("realNumber")),
                new BagExpression(new NameTerminal("integerNumber"))
             );
    
        IAbstractQueryResult queryResult14 = interpreter.eval(expression14);
        System.out.println("bag(234.35) - bag(10) = "+queryResult14.toString());
        
        // bag(234.35) == bag(10)
        IExpression expression15 = 
                 new EqualsExpression(
                         new BagExpression(new NameTerminal("realNumber")),
                         new BagExpression(new NameTerminal("integerNumber"))
                 );
        
        IAbstractQueryResult queryResult15 = interpreter.eval(expression15);
        System.out.println("(bag(234.35) == bag(10)) = "+queryResult15.toString());
        
        // bag(234.35) == bag(234.35)
        IExpression expression16 = 
                 new EqualsExpression(
                         new BagExpression(new NameTerminal("realNumber")),
                         new BagExpression(new NameTerminal("realNumber"))
                 );
        
        IAbstractQueryResult queryResult16 = interpreter.eval(expression16);
        System.out.println("(bag(234.35) == bag(234.35)) = "+queryResult16.toString());
        
        // 10 == true
        IExpression expression17 = 
                 new EqualsExpression(
                        new NameTerminal("integerNumber"),
                        new BooleanTerminal(true)
                 );
        
        IAbstractQueryResult queryResult17 = interpreter.eval(expression17);
        System.out.println("(10 == true) = "+queryResult17.toString());
        
        // 10 == 10
        IExpression expression18 = 
                 new EqualsExpression(
                        new NameTerminal("integerNumber"),
                        new NameTerminal("integerNumber")
                 );
        
        IAbstractQueryResult queryResult18 = interpreter.eval(expression18);
        System.out.println("(10 == 10) = "+queryResult18.toString());
        
        // 234.35 == 10
        IExpression expression19 =
                 new EqualsExpression(
                         new BagExpression(new NameTerminal("realNumber")),
                         new BagExpression(new NameTerminal("integerNumber"))
                 );
        
        IAbstractQueryResult queryResult19 = interpreter.eval(expression19);
        System.out.println("(234.35 == 10) = "+queryResult19.toString());


        // bag(234.35) != bag(10)
        IExpression expression20 = 
                 new NotEqualsExpression(
                         new BagExpression(new NameTerminal("realNumber")),
                         new BagExpression(new NameTerminal("integerNumber"))
                 );
        
        IAbstractQueryResult queryResult20 = interpreter.eval(expression20);
        System.out.println("(bag(234.35) != bag(10)) = "+queryResult20.toString());
        
        // 234.35 != true
        IExpression expression21 = 
                 new NotEqualsExpression(
                        new NameTerminal("realNumber"),
                        new BooleanTerminal(true)
                 );
        
        IAbstractQueryResult queryResult21 = interpreter.eval(expression21);
        System.out.println("(234.35 != true) = "+queryResult21.toString());
        
        // 234.35 != 234.35
        IExpression expression22 = 
                 new NotEqualsExpression(
                         new BagExpression(new NameTerminal("realNumber")),
                         new BagExpression(new NameTerminal("realNumber"))
                 );
        
        IAbstractQueryResult queryResult22 = interpreter.eval(expression22);
        System.out.println("(234.35 != 234.35) = "+queryResult22.toString());
        
        // 10 != "5"
        IExpression expression23 = 
                 new NotEqualsExpression(
                        new NameTerminal("integerNumber"),
                        new StringTerminal("5")
                 );
        
        IAbstractQueryResult queryResult23 = interpreter.eval(expression23);
        System.out.println("(10 != \"5\") = "+queryResult23.toString());
        
        // 10 != bag(10)
        IExpression expression24 =
                 new NotEqualsExpression(
                        new NameTerminal("integerNumber"),
                        new BagExpression(new NameTerminal("integerNumber"))
                 );
        
        IAbstractQueryResult queryResult24 = interpreter.eval(expression24);
        System.out.println("(10 != bag(10)) = "+queryResult24.toString());
       
        // bag(10) + (bag(10) - 10)
        IExpression expression25 =
             new PlusExpression(
                new BagExpression(new NameTerminal("integerNumber")),
                new MinusExpression(
                    new BagExpression(new IntegerTerminal(10)),
                    new NameTerminal("integerNumber")
                )
             );
    
        IAbstractQueryResult queryResult25 = interpreter.eval(expression25);
        System.out.println("(bag(10) + (bag(10) - 10)) = "+queryResult25.toString());
    
        // bag(10, 234.35) as someName
        IExpression expression26 =
                new AsExpression(
                    new BagExpression(
                        new CommaExpression(
                            new NameTerminal("integerNumber"),
                            new NameTerminal("realNumber")
                        )
                    ),
                    new NameTerminal("someName").getName()
                );
    
        IAbstractQueryResult queryResult26 = interpreter.eval(expression26);
        System.out.println("bag(10, 234.35) as someName = "+queryResult26.toString());

        // (bag(234.35, 10)) groupAs someName
        IExpression expression27 =
                new GroupAsExpression(
                    new BagExpression(
                        new CommaExpression(
                            new NameTerminal("realNumber"),
                            new NameTerminal("integerNumber")
                        )
                    ),
                    new NameTerminal("someName").getName()
                );
    
        IAbstractQueryResult queryResult27 = interpreter.eval(expression27);
        System.out.println("(bag(234.35, 10)) groupAs someName = "+queryResult27.toString());
        
        // min(bag(10, 234.35))
        IExpression expression28 =
                new MinExpression(
                    new BagExpression(
                        new CommaExpression(
                            new NameTerminal("integerNumber"),
                            new NameTerminal("realNumber")
                        )
                    )
                );
    
        IAbstractQueryResult queryResult28 = interpreter.eval(expression28);
        System.out.println("min(bag(10, 234.35)) = "+queryResult28.toString());
        
        // max(bag(234.35, 10))
        IExpression expression29 =
                new MaxExpression(
                    new BagExpression(
                        new CommaExpression(
                            new NameTerminal("realNumber"),
                            new NameTerminal("integerNumber")
                        )
                    )
                );
    
        IAbstractQueryResult queryResult29 = interpreter.eval(expression29);
        System.out.println("max(bag(234.35, 10)) = "+queryResult29.toString());
        
        // sum(bag(10, 234.35))
        IExpression expression30 =
                new SumExpression(
                    new BagExpression(
                        new CommaExpression(
                            new NameTerminal("integerNumber"),
                            new NameTerminal("realNumber")
                        )
                    )
                );
    
        IAbstractQueryResult queryResult30 = interpreter.eval(expression30);
        System.out.println("sum(bag(10, 234.35)) = "+queryResult30.toString());
        
        // avg(bag(10, 234.35))
        IExpression expression31 =
                new AvgExpression(
                    new BagExpression(
                        new CommaExpression(
                            new NameTerminal("integerNumber"),
                            new NameTerminal("realNumber")
                        )
                    )
                );
    
        IAbstractQueryResult queryResult31 = interpreter.eval(expression31);
        System.out.println("avg(bag(10, 234.35)) = "+queryResult31.toString());

        IExpression expression32 = 
                new PlusExpression(
                        new NameTerminal("integerNumber"),
                        new NameTerminal("integerNumber")
                );
        
        IAbstractQueryResult queryResult32 = interpreter.eval(expression32);
        System.out.println("10 + 10 = " + queryResult32.toString());

        // minus
        IExpression expression33 = 
                new MinusExpression(
                		new NameTerminal("integerNumber"),
                        new NameTerminal("integerNumber")
                );
        
        IAbstractQueryResult queryResult33 = interpreter.eval(expression33);
        System.out.println("10 - 10 = " + queryResult33.toString());
        
        // plus
        IExpression expression34 = 
                new PlusExpression(
                        new NameTerminal("integerNumber"),
                        new NameTerminal("realNumber")
                );
        
        IAbstractQueryResult queryResult34 = interpreter.eval(expression34);
        System.out.println("10 + 234.35 = " + queryResult34.toString());
        
        // count(10)
        IExpression expression35 = 
                new CountExpression(new NameTerminal("integerNumber"));
        
        IAbstractQueryResult queryResult35 = interpreter.eval(expression35);
        System.out.println("count(10) = " + queryResult35.toString());

        // count(234.35)
        IExpression expression36 = 
                new CountExpression(new NameTerminal("realNumber"));
        
        IAbstractQueryResult queryResult36 = interpreter.eval(expression36);
        System.out.println("count(234.35) = " + queryResult36.toString());

        // count(emp.name)
        IExpression expression37 = 
                new CountExpression(
                    new DotExpression(
                        new NameTerminal("emp"),
                        new NameTerminal("fName")
                    )
                );
        
        IAbstractQueryResult queryResult37 = interpreter.eval(expression37);
        System.out.println("count(emp.name) = " + queryResult37.toString());
        
        // 10 union 10
        IExpression expression38 = 
                new UnionExpression(
                    new NameTerminal("integerNumber"),
                    new NameTerminal("integerNumber")
                );
        
        IAbstractQueryResult queryResult38 = interpreter.eval(expression38);
        System.out.println("10 union 10 = " + queryResult38.toString());
        
        // bag(10) union 10
        IExpression expression39 = 
                new UnionExpression(
                    new BagExpression(new NameTerminal("integerNumber")),
                    new NameTerminal("integerNumber")
                );
        
        IAbstractQueryResult queryResult39 = interpreter.eval(expression39);
        System.out.println("bag(10) union 10 = " + queryResult39.toString());
        
        // bag(10) union bag(10)
        IExpression expression40 = 
                new UnionExpression(
                    new BagExpression(new NameTerminal("integerNumber")),
                    new BagExpression(new NameTerminal("integerNumber"))
                );
        
        IAbstractQueryResult queryResult40 = interpreter.eval(expression40);
        System.out.println("bag(10) union bag(10) = " + queryResult40.toString());

        // 1 union 10
        IExpression expression41 = 
                new UnionExpression(
                    new IntegerTerminal(1),
                    new NameTerminal("integerNumber")
                );
        
        IAbstractQueryResult queryResult41 = interpreter.eval(expression41);
        System.out.println("1 union 10 = " + queryResult41.toString());
                
        // 2 union bag(10)
        IExpression expression42 = 
                new UnionExpression(
                    new IntegerTerminal(2),
                    new BagExpression(new NameTerminal("integerNumber"))
                );
        
        IAbstractQueryResult queryResult42 = interpreter.eval(expression42);
        System.out.println("2 union bag(10) = " + queryResult42.toString());
        
        // 10 in bag(10)
        IExpression expression43 = 
        new InExpression(
            new NameTerminal("integerNumber"),
            new BagExpression(new NameTerminal("integerNumber"))
        );
        
        IAbstractQueryResult queryResult43 = interpreter.eval(expression43);
        System.out.println("10 in bag(10) = " + queryResult43.toString());
        
        // bag(10) in bag(10)
        IExpression expression44 = 
        new InExpression(
            new BagExpression(new NameTerminal("integerNumber")),
            new BagExpression(new NameTerminal("integerNumber"))
        );
        
        IAbstractQueryResult queryResult44 = interpreter.eval(expression44);
        System.out.println("bag(10) in bag(10) = " + queryResult44.toString());
        
        // bag(10) in bag(2)
        IExpression expression45 = 
        new InExpression(
            new BagExpression(new NameTerminal("integerNumber")),
            new BagExpression(new IntegerTerminal(2))
        );
        
        IAbstractQueryResult queryResult45 = interpreter.eval(expression45);
        System.out.println("bag(10) in bag(2) = " + queryResult45.toString());
        
        // 10 in bag(2)
        IExpression expression46 = 
        new InExpression(
            new NameTerminal("integerNumber"),
            new BagExpression(new IntegerTerminal(2))
        );
        
        IAbstractQueryResult queryResult46 = interpreter.eval(expression46);
        System.out.println("10 in bag(2) = " + queryResult46.toString());

        // minusSet
        IExpression expression47 = 
                new MinusSetExpression(
                        new NameTerminal("integerNumber"),
                        new NameTerminal("integerNumber")
                );
        
        IAbstractQueryResult queryResult47 = interpreter.eval(expression47);
        System.out.println("10 minusSet 10 = "+queryResult47.toString());

        // minusSet
        IExpression expression48 = 
                new MinusSetExpression(
                        new BagExpression(new NameTerminal("integerNumber")),
                        new BagExpression(new NameTerminal("integerNumber"))
                );
        
        IAbstractQueryResult queryResult48 = interpreter.eval(expression48);
        System.out.println("bag(10) minusSet bag(10) = "+queryResult48.toString());
        
        // minusSet
        IExpression expression49 =
                new MinusSetExpression(
                    new StructExpression(
                        new CommaExpression(
                            new NameTerminal("integerNumber"),
                            new CommaExpression(
                                new NameTerminal("realNumber"),
                                new IntegerTerminal(2)
                            )
                        )
                    ),
                    new StructExpression(
                        new CommaExpression(
                            new NameTerminal("integerNumber"),
                            new IntegerTerminal(3)
                        )    
                    )
                );
        
        IAbstractQueryResult queryResult49 = interpreter.eval(expression49);
        System.out.println("struct(10, 234.35, 2) minusSet struct(10, 3) = " + queryResult49.toString());
        
        // minusSet
        IExpression expression50 =
                new MinusSetExpression(
                    new StructExpression(
                        new CommaExpression(
                            new IntegerTerminal(1),
                            new IntegerTerminal(2)
                        )
                    ),
                    new StructExpression(
                        new CommaExpression(
                            new IntegerTerminal(2),
                            new IntegerTerminal(3)
                        )
                    )                    
                );
        
        IAbstractQueryResult queryResult50 = interpreter.eval(expression50);
        System.out.println("struct(1,2) minusSet struct(2,3) = " + queryResult50.toString());
        
        /*
         * struct(1,2) minus struct(2,3) should be struct(1,2)
         * but it returns
         * bag(0=struct(0=1, 1=2))
         */
        
        // bag(234.35, 10, 2) groupAs someName
        IExpression expression51 =
                new GroupAsExpression(
                    new BagExpression(
                        new CommaExpression(
                            new CommaExpression(
                                new NameTerminal("realNumber"),
                                new NameTerminal("integerNumber")
                            ),
                            new IntegerTerminal(2)
                        )
                    ),
                    new NameTerminal("someName").getName()
                );
    
        IAbstractQueryResult queryResult51 = interpreter.eval(expression51);
        System.out.println("bag(234.35, 10, 2) groupAs someName = "+queryResult51.toString());
        
        // 10 as someName
        IExpression expression52 =
                new AsExpression(
                    new NameTerminal("integerNumber"),
                    new NameTerminal("someName").getName()
                );
    
        IAbstractQueryResult queryResult52 = interpreter.eval(expression52);
        System.out.println("10 as someName = "+queryResult52.toString());

        // bag(234.35, 10) as someName
        IExpression expression53 =
                new AsExpression(
                    new BagExpression(
                        new CommaExpression(
                            new NameTerminal("realNumber"),
                            new NameTerminal("integerNumber")
                        )
                    ),
                    new NameTerminal("someName").getName()
                );
    
        IAbstractQueryResult queryResult53 = interpreter.eval(expression53);
        System.out.println("bag(234.35, 10) as someName = "+queryResult53.toString());
        
        // (234.35, 10) as someName
        IExpression expression54 =
                new AsExpression(
                    new CommaExpression(
                        new NameTerminal("realNumber"),
                        new NameTerminal("integerNumber")
                    ),
                    new NameTerminal("someName").getName()
                );
    
        IAbstractQueryResult queryResult54 = interpreter.eval(expression54);
        System.out.println("(234.35, 10) as someName = "+queryResult54.toString());

        
        IExpression expression55 = 
        		new DotExpression(
        				new NameTerminal("emp"),
        				new NameTerminal("fName")
        		);
        
        IAbstractQueryResult queryResult55 = interpreter.eval(expression55);
        System.out.println(queryResult55);
        
        IExpression expression56 =
                new AvgExpression(
                    new BagExpression(
                        new CommaExpression(
                            new NameTerminal("integerNumber"),
                            new NameTerminal("integerNumber")
                        )
                    )
                );
    
        IAbstractQueryResult queryResult56 = interpreter.eval(expression56);
        System.out.println("avg(bag(10, 10)) = "+queryResult56.toString());

        IExpression expression57 =
                new SumExpression(
                    new BagExpression(
                        new CommaExpression(
                        	new NameTerminal("integerNumber"),
                        	new NameTerminal("integerNumber")
                        )
                    )
                );
    
        IAbstractQueryResult queryResult57 = interpreter.eval(expression57);
        System.out.println("sum(bag(10, 10)) = "+queryResult57.toString());
        
        IExpression expression58 =
                new MaxExpression(
                    new BagExpression(
                        new CommaExpression(
                        	new NameTerminal("integerNumber"),
                        	new NameTerminal("integerNumber")
                        )
                    )
                );
    
        IAbstractQueryResult queryResult58 = interpreter.eval(expression58);
        System.out.println("max(bag(10, 10)) = "+queryResult58.toString());
        
        IExpression expression59 =
                new AsExpression(
                    new BagExpression(
                        new CommaExpression(
                        	new NameTerminal("integerNumber"),
                        	new NameTerminal("integerNumber")
                        )
                    ),
                    new NameTerminal("someName").getName()
                );
    
        IAbstractQueryResult queryResult59 = interpreter.eval(expression59);
        System.out.println("bag(10, 10) as someName = "+queryResult59.toString());

        IExpression expression60 =
                new GroupAsExpression(
                    new BagExpression(
                        new CommaExpression(
                        	new NameTerminal("integerNumber"),
                        	new NameTerminal("integerNumber")
                        )
                    ),
                    new NameTerminal("someName").getName()
                );
    
        IAbstractQueryResult queryResult60= interpreter.eval(expression60);
        System.out.println("(bag(10, 10)) groupAs someName = "+queryResult60.toString());
        
        IExpression expression61 =
                new MinExpression(
                    new BagExpression(
                        new CommaExpression(
                        	new NameTerminal("integerNumber"),
                            new NameTerminal("integerNumber")
                        )
                    )
                );
    
        IAbstractQueryResult queryResult61 = interpreter.eval(expression61);
        System.out.println("min(bag(10, 10)) = "+queryResult61.toString());
        
        IExpression expression62 =
                new UniqueExpression(
                    new BagExpression(
                        new CommaExpression(
                        	new NameTerminal("integerNumber"),
                        	new CommaExpression(
                        			new NameTerminal("integerNumber"),
                        			new NameTerminal("integerNumber")
                        	)
                        )
                    )
                );
        
        IAbstractQueryResult queryResult62 = interpreter.eval(expression62);
        System.out.println("unique(bag(10, 10)) = " + queryResult62.toString());
        
        IExpression expression64 =
                new StructExpression(
                	new CommaExpression(
                        new NameTerminal("integerNumber"),
                        new CommaExpression(
                        	new NameTerminal("integerNumber"),
                        	new NameTerminal("integerNumber")
                        )
                	)    
                );
        
        IAbstractQueryResult queryResult64 = interpreter.eval(expression64);
        System.out.println("struct(10, 10, 10) = " + queryResult64.toString());
        
        IExpression expression65 =
                new NotExpression(
                	    new BooleanTerminal(true)
                );
        
        IAbstractQueryResult queryResult65 = interpreter.eval(expression65);
        System.out.println("not(true) = " + queryResult65.toString());
        
        IExpression expression66 =
                new JoinExpression(
                	    new NameTerminal("integerNumber"),
                	    new NameTerminal("realNumber")
                );
        
        IAbstractQueryResult queryResult66 = interpreter.eval(expression66);
        System.out.println("join(integerNumber, realNumber) = " + queryResult66.toString());
        
        // 10 group as someName
        IExpression expression67 =
                new GroupAsExpression(
                    new NameTerminal("integerNumber"),
                    new NameTerminal("someName").getName()
                );
    
        IAbstractQueryResult queryResult67 = interpreter.eval(expression67);
        System.out.println("10 group as someName = "+queryResult67.toString());

        // 2 group as someName
        IExpression expression68 =
                new GroupAsExpression(
                    new IntegerTerminal(2),
                    new NameTerminal("someName").getName()
                );
    
        IAbstractQueryResult queryResult68 = interpreter.eval(expression68);
        System.out.println("2 group as someName = "+queryResult68.toString());

        // (fName where Anna).address.street
        IExpression expression69 =
                new DotExpression(
                    new DotExpression(
                        new WhereExpression(
                            new NameTerminal("fName"),
                            new NameTerminal("Anna")
                        ),
                        new NameTerminal("address")
                    ),
                    new NameTerminal("street")
                );
        
        IAbstractQueryResult queryResult69 = interpreter.eval(expression69);
        System.out.println("(fName where Anna).address.street = "+queryResult69.toString());

        // ((fName where Anna).address.street) union (someName)
        IExpression expression70 = 
                new UnionExpression(
                    new DotExpression(
                        new DotExpression(
                            new WhereExpression(
                                new NameTerminal("fName"),
                                new NameTerminal("Anna")
                            ),
                            new NameTerminal("address")
                        ),
                        new NameTerminal("street")
                    ),
                    new NameTerminal("someName")
                );
        
        IAbstractQueryResult queryResult70 = interpreter.eval(expression70);
        System.out.println("((fName where Anna).address.street) union (someName) = "+queryResult70.toString());

        // emp where (fName in (bag("Anna", "Maciej")))
        IExpression expression71 =
                new WhereExpression(
                    new NameTerminal("emp"),
                    new InExpression(
                        new NameTerminal("fName"),
                        new BagExpression(
                            new CommaExpression(
                                new StringTerminal("Anna"),
                                new StringTerminal("Maciej")
                            )
                        )
                    )
                );
        
        IAbstractQueryResult queryResult71 = interpreter.eval(expression71);
        System.out.println("emp where (fName in (bag(\"Anna\", \"Maciej\"))) = "+queryResult71.toString());
       
        // (emp where nazwa="Maciej").(address where zip="00-111")
        IExpression expression72 =
                new DotExpression(
                    new WhereExpression(
                        new NameTerminal("emp"),
                        new EqualsExpression(
                            new NameTerminal("fName"),
                            new StringTerminal("Maciej")
                        )
                    ),
                    new WhereExpression(
                        new NameTerminal("address"),
                        new EqualsExpression(
                            new NameTerminal("zip"),
                            new StringTerminal("00-111")
                        )
                    )
                );
       
        IAbstractQueryResult queryResult72 = interpreter.eval(expression72);
        System.out.println("(emp where nazwa=\"Maciej\").(address where zip=\"00-111\") = "+queryResult72.toString());

        // (emp where fName = "Maciej").lName
        IExpression expression73 =
                new DotExpression(
                    new WhereExpression(
                        new NameTerminal("emp"),
                        new EqualsExpression(
                            new NameTerminal("fName"),
                            new StringTerminal("Maciej")
                        )
                    ),
                    new NameTerminal("lName")
                );
        
        IAbstractQueryResult queryResult73 = interpreter.eval(expression73);
        System.out.println("(emp where fName = \"Maciej\").lName = " + queryResult73.toString());

        // emp where fName = "Maciej"
        IExpression expression74 =
                new WhereExpression(
                    new NameTerminal("emp"),
                    new EqualsExpression(
                        new NameTerminal("fName"),
                        new StringTerminal("Maciej")
                    )
                );
        
        IAbstractQueryResult queryResult74 = interpreter.eval(expression74);
        System.out.println("emp where fName = \"Maciej\" = " + queryResult74.toString());

        // (bag(10, 234.35), bag(3+4, "test")) as someName
        IExpression expression75 =
                new AsExpression(
                    new CommaExpression(
                        new BagExpression(
                            new CommaExpression(
                                new NameTerminal("integerNumber"),
                                new NameTerminal("realNumber")
                            )
                        ),
                        new BagExpression(
                            new CommaExpression(
                                new PlusExpression(
                                    new NameTerminal("realNumber"),
                                    new NameTerminal("integerNumber")
                                ),
                                new NameTerminal("test")
                            )
                        )
                    ),
                    new NameTerminal("someName").getName()
                );

        IAbstractQueryResult queryResult75 = interpreter.eval(expression75);
        System.out.println("(bag(10, 234.35), bag(3+4, \"test\")) as someName = " + queryResult75.toString());

        // (((bag("Maciej", "Nowak")) groupas x), 2.3, true)
        IExpression expression76 =
                new CommaExpression(
                    new CommaExpression(
                        new GroupAsExpression(
                            new BagExpression(
                                new CommaExpression(
                                    new NameTerminal("Maciej"),
                                    new NameTerminal("Nowak")
                                )
                            ),
                            new NameTerminal("x").getName()
                        ),
                        new DoubleTerminal(2.3)
                    ),
                    new BooleanTerminal(true)
                );

        IAbstractQueryResult queryResult76 = interpreter.eval(expression76);
        System.out.println("(((bag(\"Maciej\", \"Nowak\")) groupas x), 2.3, true) = " + queryResult76.toString());
        
        
        // (bag("Maciej", "Nowak", "Warszawa"), (234.35*10, false))
        IExpression expression77 =
                new CommaExpression(
                    new BagExpression(
                        new CommaExpression(
                            new CommaExpression(
                                new NameTerminal("Maciej"),
                                new NameTerminal("Nowak")
                            ),
                            new NameTerminal("Warszawa")
                        )
                    ),
                    new CommaExpression(
                        new MultiplyExpression(
                            new NameTerminal("realNumber"),
                            new NameTerminal("integerNumber")
                        ),
                        new BooleanTerminal(false)
                    )
                );
        
        IAbstractQueryResult queryResult77 = interpreter.eval(expression77);
        System.out.println("(bag(\"Maciej\", \"Nowak\", \"Warszawa\"), (234.35*10, false)) = " + queryResult77.toString());
        
        // 1 * 1 union 1 + 1 union count(1, 2, 3)
        IExpression expression78 =
                new UnionExpression(
                    new UnionExpression(
                        new MultiplyExpression(
                            new IntegerTerminal(1),
                            new IntegerTerminal(1)
                        ),
                        new PlusExpression(
                            new IntegerTerminal(1),
                            new IntegerTerminal(1)
                        )
                    ),
                    new CountExpression(
                        new BagExpression(
                            new CommaExpression(
                                new CommaExpression(
                                    new IntegerTerminal(1),
                                    new IntegerTerminal(2)
                                ),
                                new IntegerTerminal(3)
                            )
                        )
                    )
                );
        
        IAbstractQueryResult queryResult78 = interpreter.eval(expression78);
        System.out.println("1 * 1 union 1 + 1 union count(1, 2, 3) = " + queryResult78.toString());
        
        // false and true
        IExpression expression79 =
                new AndExpression(
                        new BooleanTerminal(false),
                        new BooleanTerminal(true)
                    );
        
        IAbstractQueryResult queryResult79 = interpreter.eval(expression79);
        System.out.println("false and true = " + queryResult79.toString());
        
        // all 1 true
        IExpression expression80 =
                new ForAllExpression(
                    new IntegerTerminal(1),
                    new BooleanTerminal(true)
                );
        
        IAbstractQueryResult queryResult80 = interpreter.eval(expression80);
        System.out.println("all 1 true = " + queryResult80.toString());

        // all emp married
        IExpression expression81 =
                new ForAllExpression(
                    new NameTerminal("emp"),
                    new NameTerminal("married")
                );
        
        IAbstractQueryResult queryResult81 = interpreter.eval(expression81);
        System.out.println("all emp married = " + queryResult81.toString());
        
        // any 1 true
        IExpression expression82 =
                new ForAnyExpression(
                    new IntegerTerminal(1),
                    new BooleanTerminal(true)
                );
        
        IAbstractQueryResult queryResult82 = interpreter.eval(expression82);
        System.out.println("any 1 true = " + queryResult82.toString());

        // any emp married
        IExpression expression83 =
                new ForAnyExpression(
                    new NameTerminal("emp"),
                    new NameTerminal("married")
                );
        
        IAbstractQueryResult queryResult83 = interpreter.eval(expression83);
        System.out.println("any emp married = " + queryResult83.toString());
        
        // "Maciek" == "Maciek"
        IExpression expression84 =
                new EqualsExpression(
                    new StringTerminal("Maciek"),
                    new StringTerminal("Maciek")
                );
        
        IAbstractQueryResult queryResult84 = interpreter.eval(expression84);
        System.out.println("\"Maciek\" == \"Maciek\" = " + queryResult84.toString());

        // (1 as n) join n
        IExpression expression85 =
                new JoinExpression(
                    new AsExpression(
                        new IntegerTerminal(1),
                        new NameTerminal("n").getName()
                    ),
                    new NameTerminal("n")
                );
        
        IAbstractQueryResult queryResult85 = interpreter.eval(expression85);
        System.out.println("(1 as n) join n = " + queryResult85.toString());
        
        // emp join married
        IExpression expression86 =
                new JoinExpression(
                    new StructExpression(
                        new NameTerminal("emp")
                    ),
                    new StructExpression(
                        new NameTerminal("married")
                    )
                );
        
        IAbstractQueryResult queryResult86 = interpreter.eval(expression86);
        System.out.println("(emp) join (married) = " + queryResult86.toString());
        
        /*
        // 10 <= "someName"
        IExpression expression87 =
                new LessOrEqualThanExpression(
                    new NameTerminal("integerNumber"),
                    new StringTerminal("someName")
                );
        
        IAbstractQueryResult queryResult87 = interpreter.eval(expression87);
        System.out.println("10 <= \"someName\" = " + queryResult87.toString());
        */
    }
}